package main

import (
	"new_for_deepseek_rabbitmq/consumer"
	"new_for_deepseek_rabbitmq/logger"
	"new_for_deepseek_rabbitmq/model"
	"new_for_deepseek_rabbitmq/project/rabbitmq"
	"new_for_deepseek_rabbitmq/project/redis"
)

func main() {

	//初始化mysql
	if err := model.Initialize(); err != nil {
		logger.Error("Failed to initialize MySQL: %s", err.Error())
		return
	}

	// 初始化 RabbitMQ
	if err := rabbitmq.InitRabbitMQ(); err != nil {
		logger.Error("Failed to initialize RabbitMQ: %s", err.Error())
		return
	}

	// 初始化 Redis
	if err := redis.InitRedis(); err != nil {
		logger.Error("Failed to initialize Redis: %s", err.Error())
		return
	}

	// 启动消费者
	go func() {
		newsConsumer := consumer.NewsConsumer()
		if err := newsConsumer.Start(); err != nil {
			logger.Error("启动新闻消费者失败: %v", err)
		}
	}()

	go func() {
		qaConsumer := consumer.QuestionAnswer()
		if err := qaConsumer.Start(); err != nil {
			logger.Error("启动问答消费者失败: %v", err)
		}
	}()

	go func() {
		syncConsumer := consumer.SyncConsumer()
		if err := syncConsumer.Start(); err != nil {
			logger.Error("启动同步消费者失败: %v", err)
		}
	}()

	// 阻塞主线程
	select {}

}
